package com.unionServer.common;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.ParseException;

/**
 * @description:
 * @author: wangxinal
 * @time: 2022/1/19 17:26
 */
public class LBCDAsciiConverter {

    private static final Log log = LogFactory.getLog(LBCDAsciiConverter.class);
    private static final String DEFAULT_ENCODING = "utf-8";
    private static final char DEFAULT_FILLCHAR = ' ';

    public LBCDAsciiConverter() {
    }

    public String bcd2Ascii(byte[] bytes) {
        StringBuffer temp = new StringBuffer(bytes.length * 2);

        for(int i = 0; i < bytes.length; ++i) {
            byte hight = (byte)((bytes[i] & 240) >>> 4);
            byte low = (byte)(bytes[i] & 15);
            temp.append(hight);
            temp.append(low);
        }

        return temp.toString();
    }

}
